package boot3.mapper;

import boot3.pojo.Chatroom;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ChatroomMapper {
    //获取所有的聊天室
    @Select("select * from chatroom")
    public List<Chatroom> findAll();
    //创建聊天室
    @Insert("insert chatroom(chatroom_id,project_name,start_time,admin_id,is_private,admin_name)" +
            " value(#{chatroom_id},#{project_name},#{start_time},#{admin_id},#{isPrivate},#{admin_name})")
    public Boolean createChatroom(String chatroom_id,String project_name,
                                  String start_time,String admin_id,Boolean isPrivate,String admin_name);
    //根据聊天室的ID删除指定的聊天室
    @Delete("delete from chatroom where chatroom_id=#{chatroom_id}")
    public Boolean deleteChatroom(String chatroom_id);
    //根据聊天室的ID获取聊天室管理员的ID
    @Select("select admin_id from chatroom where chatroom_id=#{chatroom_id} ")
    public String getLiveroomAdminID(String chatroom_id);
    //更改某个聊天室的在线人数
    @Update("update chatroom set onlineNumber=#{onlineNumber} where chatroom_id=#{chatroom_id}")
    public Boolean updateChatroom(String chatroom_id,int onlineNumber);
    //根据聊天室ID获取指定的聊天室
    @Select("select * from chatroom where chatroom_id=#{chatroom_id}")
    public Chatroom findChatroom(String chatroom_id);
}
